<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .outer {
            width: 800px;
            height: 400px;
            background-color: pink;
            overflow: hidden;
        }

        .box {
            width: 100px;
            height: 100px;
            /* margin的百分比相对父元素的宽度 */
            margin-left: 20%;
            margin-top: 20%;
            background-color: red;
        }
    </style>
</head>

<body>
    <div class="outer">
        <div class="box"></div>
    </div>
</body>

</html>